#include <iostream>
#include <vector>
#include <map>
using namespace std;
const int N = 22;
int dx[N];
int dy[N];
int mp[N][N];
int n;
int ddx[4] = { -1,0,1,0 };
int ddy[4] = { 0,1,0,-1 };
int st[N][N];
vector<int>ans;
bool dfs(int x, int y)
{
    if (x == n && y == n) {
        bool f = 0;
        for (int i = 1; i <= n; i++) {
            if (dx[i] != 0)f = 1;
        }
        for (int i = 1; i <= n; i++) {
            if (dy[i] != 0)f = 1;
        }
        if (!f) {
            for (auto x : ans) {
                cout << x << " ";
            }
            return 1;
        }
        return 0;
    }
    for (int i = 0; i < 4; i++) {
        int a = ddx[i] + x;
        int b = ddy[i] + y;
        if (a >= 1 && a <= n && b >= 1 && b <= n && !st[a][b]) {
            if (dx[a] <= 0 || dy[b] <= 0)continue;
            cout << "a==" << a << endl;
            cout << "b==" << b << endl;
            st[a][b] = 1;
            ans.push_back(mp[a][b]);
            dx[a]--;
            dy[b]--;
            if (dfs(a, b)) {
                return 1;
            }
            dx[a]++;
            dy[b]++;
            st[a][b] = 0;
            ans.pop_back();
        }
    }
    return 0;
}
int main()
{
    int cnt = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            mp[i][j] = cnt++;
        }
    }
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        dy[i] = x;
    }
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        dx[i] = x;
    }
    st[1][1] = 1;
    dx[1]--, dy[1]--;
    ans.push_back(mp[1][1]);
    dfs(1,1);
    return 0;
}